package com.altius.twitapp;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class TwitViewerBean {
    private List<Twit> twits;

    public TwitViewerBean() {
        twits = new ArrayList<Twit>();
        twits.add(new Twit("Hello World!", Calendar.getInstance().getTime()));
    }
    
    public void sort(List<Twit> list) {
        Collections.sort(list, new Comparator<Twit>() {

            @Override
            public int compare(Twit arg0, Twit arg1) {
                if (arg0.getDate().before(arg1.getDate())) {
                    return 1;
                }
                return 0;
            }
            
        });
    }

    public void setTwits(List<Twit> twits) {
        this.twits = twits;
    }

    public List<Twit> getTwits() {
        return twits;
    }
}
